package com.ruoyi.projects.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.projects.domain.SlOperateLog;
import com.ruoyi.projects.service.ISlOperateLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 实操记录Controller
 * 
 * @author yangz
 * @date 2024-12-02
 */
@RestController
@RequestMapping("/projects/SlOperateLog")
public class SlOperateLogController extends BaseController
{
    @Autowired
    private ISlOperateLogService slOperateLogService;

    /**
     * 查询实操记录列表
     */
    @PreAuthorize("@ss.hasPermi('projects:SlOperateLog:list')")
    @GetMapping("/list")
    public TableDataInfo list(SlOperateLog slOperateLog)
    {
        startPage();
        List<SlOperateLog> list = slOperateLogService.selectSlOperateLogList(slOperateLog);
        return getDataTable(list);
    }

    /**
     * 导出实操记录列表
     */
    @PreAuthorize("@ss.hasPermi('projects:SlOperateLog:export')")
    @Log(title = "实操记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SlOperateLog slOperateLog)
    {
        List<SlOperateLog> list = slOperateLogService.selectSlOperateLogList(slOperateLog);
        ExcelUtil<SlOperateLog> util = new ExcelUtil<SlOperateLog>(SlOperateLog.class);
        util.exportExcel(response, list, "实操记录数据");
    }

    /**
     * 获取实操记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('projects:SlOperateLog:query')")
    @GetMapping(value = "/{operateId}")
    public AjaxResult getInfo(@PathVariable("operateId") Long operateId)
    {
        return AjaxResult.success(slOperateLogService.selectSlOperateLogByOperateId(operateId));
    }

    /**
     * 新增实操记录
     */
    @PreAuthorize("@ss.hasPermi('projects:SlOperateLog:add')")
    @Log(title = "实操记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SlOperateLog slOperateLog)
    {
        return toAjax(slOperateLogService.insertSlOperateLog(slOperateLog));
    }

    /**
     * 修改实操记录
     */
    @PreAuthorize("@ss.hasPermi('projects:SlOperateLog:edit')")
    @Log(title = "实操记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SlOperateLog slOperateLog)
    {
        return toAjax(slOperateLogService.updateSlOperateLog(slOperateLog));
    }

    /**
     * 删除实操记录
     */
    @PreAuthorize("@ss.hasPermi('projects:SlOperateLog:remove')")
    @Log(title = "实操记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{operateIds}")
    public AjaxResult remove(@PathVariable Long[] operateIds)
    {
        return toAjax(slOperateLogService.deleteSlOperateLogByOperateIds(operateIds));
    }
}
